package cn.edu.service.impl;

import cn.edu.dao.Col_TeacherDao;
import cn.edu.domain.*;

import cn.edu.service.Col_TeacherService;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Davey chan
 */
@Service
public  class Col_TeacherServiceImpl implements Col_TeacherService {
  @Autowired
    private Col_TeacherDao TeacherDao;


    @Override
    public PageBean<All> selectByPageAndcondition(int currentPage, int pageSize,String academyName, All t) {

        int begin=(currentPage-1)*pageSize;
//        计算查询的条目数
        int size =pageSize;
//        处理查询条件，模糊查询
        String teacherName = t.getTeacherName();
        if(teacherName !=null && teacherName.length()>0){
            t.setTeacherName("%"+teacherName+"%");
        }
//        String status = t.getStatus();
//        if(status !=null && status.length()>0){
//            t.setStatus("%"+status+"%");
//
//        }
        t.setExamstatus("3");
        System.out.println(t.getExamstatus());
        academyName="%"+academyName+"%";
        t.setAcademyName(academyName);


        List<All> rows = TeacherDao.selectBypageAndCondtion(begin, size,t);
//        查询总记录数
        int totalCount = TeacherDao.selectTotalCountByCondition(t);
//封装pageBean

        PageBean<All> pageBean=new PageBean<>();
        pageBean.setRows(rows);
        pageBean.setTotalCount(totalCount);
        return pageBean;
    }

    @Override
    public void delteacher(Integer id) {
        TeacherDao.delteacher(id);
    }
    @Override
    public void Updateteacher(All t) {
        TeacherDao.UpdateTeacher(t);
    }

    @Override
    public List<thesis> getThesis(Integer id) {
        List<thesis> thesis = TeacherDao.getThesis(id);
        return thesis;
    }

    @Override
    public List<research_project> getResearch_project(Integer id) {
        List<research_project> research_project = TeacherDao.getResearch_project(id);
        return research_project;

    }

    @Override
    public List<annual_examination> getAnnual_examination(Integer id) {
        List<annual_examination> annual_examination = TeacherDao.getAnnual_examination(id);

        return annual_examination;
    }

    @Override
    public List<award> getAward(Integer id) {
        List<award> award = TeacherDao.getAward(id);
        return award;
    }

    @Override
    public List<honor_title> getHonor_title(Integer id) {
        List<honor_title> honor_title = TeacherDao.getHonor_title(id);

        return honor_title;
    }

    @Override
    public List<opus> getOpus(Integer id) {
        List<opus> opus = TeacherDao.getOpus(id);
        return opus;
    }

    @Override
    public List<teach_work> getTeach_work(Integer id) {
        List<teach_work> teach_work = TeacherDao.getTeach_work(id);
        return teach_work;
    }

    @Override
    public List<train> getTrain(Integer id) {
        List<train> train = TeacherDao.getTrain(id);
        return train;
    }

    @Override
    public List<patent> getPatent(Integer id) {
        List<patent> patent = TeacherDao.getPatent(id);
        return patent;
    }

    @Override
    public List<work> getWork(Integer id) {
        List<work> work = TeacherDao.getWork(id);
        return work;
    }


}
